<div class="box-tools" style="top:10px;">
  <form class="form-inline" id="project—form" action="{:url('money/support')}" method="GET" pjax-search="">
    <div class="form-group">
      <label for="project_id">所属项目</label>
      <select class="form-control" name="project_id" id="project_id" style="border-radius:3px;">
        <option value="">全部</option>
        {volist name="ProjectList" id="project"}
        <option value="{$project.id}" {if condition="input('project_id') eq $project.id" }selected="selected" {/if} >{$project.project_name}</option>
        {/volist}
      </select>
    </div>
    <div class="form-group">
      <label for="status">订单状态</label>
      <select class="form-control" name="status" id="status" style="border-radius:3px;">
        <option value="-1">全部</option>
        <option value="2" {if condition="input('get.status') eq 2" }selected="selected" {/if} >已成功</option>
        <option value="0" {if condition="input('get.status') === '0'" }selected="selected" {/if} >未成功</option>
        <option value="1" {if condition="input('get.status') eq 1" }selected="selected" {/if} >其他状态</option>
      </select>
    </div>
    <div class="form-group">
      <label for="payment_status">代付状态</label>
      <select class="form-control" name="payment_status" id="payment_status" style="border-radius:3px;">
        <option value="-1">全部</option>
        <option value="2" {if condition="input('get.payment_status') eq 2" }selected="selected" {/if} >已失败</option>
        <option value="0" {if condition="input('get.payment_status') === '0'" }selected="selected" {/if} >待处理</option>
        <option value="1" {if condition="input('get.payment_status') eq 1" }selected="selected" {/if} >已成功</option>
      </select>
    </div>
    <div class="form-group">
      <label for="start_date">开始时间</label>
      <input style="width: 100px" class="form-control timepicker" autocomplete="off" id="start_date" name="start_date"
             value="{:input('get.start_date')}" placeholder="开始时间">
    </div>
    <div class="form-group">
      <label for="end_date">结束时间</label>
      <input style="width: 100px" class="form-control timepicker" autocomplete="off" id="end_date" name="end_date"
             value="{:input('get.end_date')}" placeholder="结束时间">
    </div>
    <div class="form-group">
      <label for="search">关键字</label>
      <input type="text" name="search" id="search" class="form-control" value="{:input('get.search')}"
             placeholder="按会员名称搜索"/>
    </div>
    <div class="form-group">
      <button type="submit" class="btn btn-primary sreachs">搜索</button>
      <button type="button" id="dwonload" class="btn btn-primary sreachs">下载</button>
      <button type="button" class="btn btn-primary" onclick="resetForm()">重置</button>
    </div>
  </form>
</div>
<script>
    $(function () {
        $('#dwonload').click(function () {
            var url = "{:url('project/order')}";
            var project_id = $("select[name='project_id']").val();
            var status = $("select[name='status']").val();
            var start_date = $("input[name='start_date']").val();
            var end_date = $("input[name='end_date']").val();
            var search = $("input[name='search']").val();
            location.href = url + "?project_id=" + project_id + "&status=" + status + "&start_date=" + start_date + "&end_date=" + end_date + "&search=" + search + "&down=1";
        })
        let start_date = $('#start_date').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn'),
        }).on('dp.change', function (e) {
           let initEndDate = $('#end_date').val()
            end_date.data('DateTimePicker').minDate(e.date);
            if(initEndDate === ''){
              $('#end_date').val('')
            }

        });
        let end_date = $('#end_date').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        }).on('dp.change', function (e) {
            start_date.data('DateTimePicker').maxDate(e.date);
        });
    })

    function resetForm() {
        $('select[name="project_id"]').val('')
        $('select[name="status"]').val('-1')
        $('select[name="payment_status"]').val('-1')
        $('input[name="start_date"]').val('')
        $('input[name="end_date"]').val('')
        $('input[name="search"]').val('')
        $('#project—form').submit()
    }
</script>